{include file="index/header"}
{$background_image|raw}
<div class="layui-fluid ew-console-wrapper">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-sm6 layui-col-md4">
            <div class="layui-card">

                <div class="layui-card-body" style="padding: 0;">
                    <div class="bgimg"></div>
                    <!-- 表格工具栏 -->
                    <img id="logo" class="img" onclick="layer.tips('应用LOGO', this, {tips: 1});"  src="{__IMG__}logo.png" width="100" height="100"/>
                    <form class="layui-card-body layui-form layui-form-pane formBasForm" id="queryAuthForm">
                        <div id="introduce" class="layui-form-item" style="display: none">
                            <div class="sf-tips">
                                <div id="introduceContent"></div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="height: 32px;border-radius: 4px;">应用名称</label>
                            <div class="layui-input-block">
                                <select name="appid" class="layui-input ew-select-fixed" lay-filter="app" lay-search lay-verify="required">
                                    <option value="">请选择应用</option>
                                    {volist name="app_list.data.data" id="res"}
                                    <option value="{$res.id}">{$res.name}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">查询内容</label>
                            <div class="layui-input-block">
                                <input type="text" name="auth_info" placeholder="请输入要查询的内容" class="layui-input"
                                       lay-verType="tips" lay-verify="required" required/>
                            </div>
                        </div>
                        <div class="layui-form-item" pane>
                            <label class="layui-form-label">查询类型</label>
                            <div class="layui-input-block">
                                <input type="radio" name="query_type" value="auth" title="授权"checked>
                                <input type="radio" name="query_type" value="user" title="代理">
                                <input type="radio" name="query_type" value="pay" title="认证">
                            </div>
                        </div>
                        <div class="layui-form-item text-right">
                            <button class="layui-btn" lay-filter="SF_QueryAuth" lay-submit>查询</button>
                            <button class="layui-btn layui-btn-primary" type="button" id="SF_QueryAuth_Reset">重置</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="layui-col-sm6 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">
                    注册用户
                    <span class="pull-right">
                    <i class="sf-avatar sf-avatar-icon sf-avatar-small sf-avatar-purple layui-icon layui-icon-user"></i>
                </span>
                </div>
                <div class="layui-card-body">
                    <form class="layui-card-body layui-form layui-form-pane formBasForm" id="registerForm">
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="height: 32px;border-radius: 4px;">应用名称</label>
                            <div class="layui-input-block">
                                <select name="appid" class="layui-input ew-select-fixed" lay-filter="register_app" lay-search lay-verify="required">
                                    <option value="">请选择应用</option>
                                    {volist name="app_list.data.data" id="res"}
                                    <option value="{$res.id}">{$res.name}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户名</label>
                            <div class="layui-input-block">
                                <input type="text" name="username" placeholder="请输入用户名" class="layui-input"
                                       lay-verType="tips" lay-verify="required" required/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">密码</label>
                            <div class="layui-input-block">
                                <input type="password" name="password" placeholder="请输入密码" class="layui-input"
                                       lay-verType="tips" lay-verify="required" required/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">确认密码</label>
                            <div class="layui-input-block">
                                <input type="password" name="confirmPassword" placeholder="请确认密码" class="layui-input"
                                       lay-verType="tips" lay-verify="required" required/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">QQ</label>
                            <div class="layui-input-block">
                                <input type="number" name="qq" placeholder="请输入要绑定的QQ" class="layui-input"
                                       lay-verType="tips" lay-verify="required" required/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">邮箱</label>
                            <div class="layui-input-block">
                                <input type="text" name="email" placeholder="请输入要绑定的邮箱" class="layui-input"
                                       lay-verType="tips" lay-verify="required" required/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">手机号</label>
                            <div class="layui-input-block">
                                <input type="number" name="phone" placeholder="请输入要绑定的手机号" class="layui-input"
                                       lay-verType="tips" lay-verify="required" required/>
                            </div>
                        </div>
                        <div class="layui-form-item text-right">
                            <button class="layui-btn" lay-filter="SF_RegisterSubmit" lay-submit>注册</button>
                            <button class="layui-btn layui-btn-primary" type="button" id="SF_Register_Reset">重置</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="myAudio1"></div>
{include file="index/footer"}
{$background_notice|raw}
{$background_music|raw}
<script>
    layui.use(['layer', 'form', 'admin', 'element', 'notice'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var notice = layui.notice;

        $("#SF_QueryAuth_Reset").click(function(){
            document.getElementById("queryAuthForm").reset();
            notice.msg('重置表单成功！', {icon: 1, audio:'1'});
            return false;
        });
        $("#SF_Download_Reset").click(function(){
            document.getElementById("downloadForm").reset();
            notice.msg('重置表单成功！', {icon: 1, audio:'1'});
            return false;
        });
        $("#SF_Register_Reset").click(function(){
            document.getElementById("registerForm").reset();
            notice.msg('重置表单成功！', {icon: 1, audio:'1'});
            return false;
        });
        form.on('select(app)', function (data) {
            if(data.value == ''){
                $("#logo").attr('src','{__IMG__}logo.png');
            }else{
                $.ajax({
                    type: "POST",
                    url: '{:url("/Ajax/appInfo")}',
                    data: {appid:data.value},
                    dataType: "json",
                    success: function(data) {
                        notice.destroy();
                        if (data.code == 0) {
                            notice.msg("获取信息成功！", {icon: 1, audio:'1'});
                            $("#introduceContent").html(data.data.introduce?data.data.introduce:'暂无介绍');
                            $("#introduce").css('display','inherit');
                            if(data.data.app_notice){
                                admin.open({
                                    type: 1,
                                    title: '应用公告',
                                    shade: .1,
                                    content: '<div class="layui-card layui-card-body">'+data.data.app_notice+'</div>'
                                });
                            }
                            $("#logo").attr('src',data.data.logo);
                        } else {
                            notice.msg(data.msg, {icon: 2, audio:'1'});
                        }
                    },
                    error: function() {
                        notice.destroy();
                        notice.msg("服务器错误！", {icon: 2, audio:'1'});
                    }
                });
            }
            return false;
        });

        form.on('select(register_app)', function (data) {
            $.ajax({
                type: "POST",
                url: '{:url("/Ajax/appInfo")}',
                data: {appid:data.value},
                dataType: "json",
                success: function(data) {
                    notice.destroy();
                    if (data.code == 0) {
                        notice.msg("获取信息成功！", {icon: 1, audio:'1'});
                        if(data.data.register_notice){
                            admin.open({
                                type: 1,
                                title: '注册公告',
                                shade: .1,
                                content: '<div class="layui-card layui-card-body">'+data.data.register_notice+'</div>'
                            });
                        }
                    } else {
                        notice.msg(data.msg, {icon: 2, audio:'1'});
                    }
                },
                error: function() {
                    notice.destroy();
                    notice.msg("服务器错误！", {icon: 2, audio:'1'});
                }
            });
            return false;
        });

        form.on('submit(SF_QueryAuth)', function (data) {
            notice.msg('正在执行中..', {icon: 4, close: true});
            $.ajax({
                type: "POST",
                url: '{:url("/Ajax/queryAuth")}',
                data: data.field,
                dataType: "json",
                success: function(data) {
                    notice.destroy();
                    if (data.code == 0) {
                        if(data.data.status == 1){
                            notice.warning({
                                title: '查询通知',
                                message: data.msg,
                                animateInside:true,
                                position:'topCenter',
                                transitionOut:'flipOutX',
                                transitionOutMobile: 'flipOutX',
                                displayMode:'2',
                                audio:'1'
                            });
                        }else{
                            notice.success({
                                title: '查询通知',
                                message: data.msg,
                                animateInside:true,
                                position:'topCenter',
                                transitionOut:'flipOutX',
                                transitionOutMobile: 'flipOutX',
                                displayMode:'2',
                                audio:'1'
                            });
                        }
                    } else {
                        notice.error({
                            title: '查询通知',
                            message: data.msg,
                            animateInside:true,
                            position:'topCenter',
                            transitionOut:'flipOutX',
                            transitionOutMobile: 'flipOutX',
                            displayMode:'2',
                            audio:'1'
                        });
                    }
                },
                error: function() {
                    notice.destroy();
                    notice.error({
                        title: '查询通知',
                        message: '服务器错误',
                        animateInside:true,
                        position:'topCenter',
                        transitionOut:'flipOutX',
                        transitionOutMobile: 'flipOutX',
                        displayMode:'2',
                        audio:'1'
                    });
                }
            });
            return false;
        });
        form.on('submit(SF_RegisterSubmit)', function (data) {
            notice.msg('正在执行中..', {icon: 4, close: true});
            $.ajax({
                type: "POST",
                url: '{:url("/Ajax/register")}',
                data: data.field,
                dataType: "json",
                success: function(data) {
                    notice.destroy();
                    if (data.code == 0) {
                        notice.success({
                            title: '注册通知',
                            message: data.msg,
                            animateInside:true,
                            position:'topCenter',
                            transitionOut:'flipOutX',
                            transitionOutMobile: 'flipOutX',
                            displayMode:'2',
                            audio:'1'
                        });
                    } else {
                        notice.error({
                            title: '注册通知',
                            message: data.msg,
                            animateInside:true,
                            position:'topCenter',
                            transitionOut:'flipOutX',
                            transitionOutMobile: 'flipOutX',
                            displayMode:'2',
                            audio:'1'
                        });
                    }
                },
                error: function() {
                    notice.destroy();
                    notice.error({
                        title: '注册通知',
                        message: '服务器错误',
                        animateInside:true,
                        position:'topCenter',
                        transitionOut:'flipOutX',
                        transitionOutMobile: 'flipOutX',
                        displayMode:'2',
                        audio:'1'
                    });
                }
            });
            return false;
        });
    });
</script>
